from flask import Flask,render_template
import sqlite3


app = Flask(__name__)


@app.route('/')
def index():  # put application's code here
    return render_template('index.html')


@app.route('/index')
def home():  # put application's code here
    return render_template('index.html')
    # return index()    # 请求转发


@app.route('/movie')
def movie():  # put application's code here
    datalist = []
    conn = sqlite3.connect('movie.db')
    c = conn.cursor()
    sql = '''select * from movie250'''
    data = c.execute(sql)
    for item in data:
        datalist.append(item)
    c.close()
    conn.close()
    return render_template('movie.html', movies=datalist)


@app.route('/score')
def score():  # put application's code here
    score = []  # 评分
    num = []    # 每个评分的电影数
    conn = sqlite3.connect('movie.db')
    c = conn.cursor()
    sql = '''select score,count(score) from movie250 group by score'''
    data = c.execute(sql)
    for item in data:
        score.append(item[0])
        num.append(item[1])
    c.close()
    conn.close()
    return render_template('score.html', score=score, num=num)


@app.route('/word')
def word():  # put application's code here
    return render_template('word.html')


@app.route('/team')
def team():  # put application's code here
    return render_template('team.html')




if __name__ == '__main__':
    app.run()
